package com.insigma.business.qrcode.soldier.util;

import org.springframework.util.CollectionUtils;

import java.util.Iterator;
import java.util.List;


public class FieldFilterUtils {


    public static List<String> filterHeader(List<String> headers, List<String> fields) {
        if (CollectionUtils.isEmpty(fields)) {
            return headers;
        }
        Iterator<String> iterator = headers.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            if (!fields.contains(next)) {
                iterator.remove();
            }
        }
        return headers;
    }
}
